package cn.bdqn.repository;

import cn.bdqn.pojo.Worklog;
import cn.bdqn.vo.UserWorkLog;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.Date;
import java.util.List;

public interface Asecu_WorkLogRepository extends JpaRepository<Worklog,Integer>, JpaSpecificationExecutor<Worklog> {

    @Query("select new cn.bdqn.vo.UserWorkLog(u,w) from  User u,Worklog w where u.id = w.userId and u.id=:id " +
            "and (:project=null or w.project like %:project%) and (:workdate = null or w.workdate=:workdate)")
    List<UserWorkLog> findWork(@Param("id") Integer id,@Param("project") String project,@Param("workdate") Date workdate);
}
